﻿package mortal.game.view.monthInvestment.view
{
    import Message.Game.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import com.mui.display.*;
    import com.mui.utils.*;
    import mortal.common.swfPlayer.data.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.rebate.item.*;

    public class MonthInvestTabCellRender extends GCellRenderer
    {
        private var _title:GImageBitmap;
        private var _isInvestIcon:GImageBitmap;
        private var _selectedBg:ScaleBitmap;
        protected var _hasReward:ScaleSwfPlayer;
        private var _type:int;

        public function MonthInvestTabCellRender()
        {
            return;
        }// end function

        override protected function initSkin() : void
        {
            var _loc_1:* = GlobalClass.getBitmap(ImagesConst.AchievemenListTabBtnBg);
            this.setStyle("downSkin", _loc_1);
            this.setStyle("overSkin", _loc_1);
            this.setStyle("upSkin", _loc_1);
            this.setStyle("selectedDownSkin", _loc_1);
            this.setStyle("selectedOverSkin", _loc_1);
            this.setStyle("selectedUpSkin", _loc_1);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._title = UIFactory.gImageBitmap("", 0, 0, this, this.setTitlePos);
            this._selectedBg = UIFactory.bg(-2, -2, 191, 61, this, ImagesConst.selectFilter);
            this._isInvestIcon = UIFactory.gImageBitmap(ImagesConst.MonthInvestTabIcon, -10, 20, this);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._title.dispose(param1);
            this._title = null;
            this._isInvestIcon.dispose(param1);
            this._isInvestIcon = null;
            this._selectedBg.dispose(param1);
            this._selectedBg = null;
            if (this._hasReward)
            {
                this._hasReward.dispose(param1);
                this._hasReward = null;
            }
            super.disposeImpl(param1);
            return;
        }// end function

        private function setTitlePos() : void
        {
            if (isDisposed)
            {
                return;
            }
            this._title.x = this.width - this._title.width >> 1;
            this._title.y = this.height - this._title.height >> 1;
            return;
        }// end function

        private function setRewardFlag(param1:Boolean) : void
        {
            if (param1)
            {
                if (this._hasReward == null)
                {
                    this._hasReward = UICompomentPool.getUICompoment(ScaleSwfPlayer);
                    this._hasReward.swf.timeRate = 5;
                    this._hasReward.scaleX = 0.95;
                    this._hasReward.scaleY = 0.8;
                    this._hasReward.load("guide_noName.swf", ModelType.NormalSwf, null);
                    this._hasReward.move(98, 35);
                    this.addChild(this._hasReward);
                }
                this._hasReward.visible = true;
                this._hasReward.swf.play();
            }
            else if (this._hasReward)
            {
                this._hasReward.visible = false;
                this._hasReward.swf.stop();
            }
            return;
        }// end function

        override public function set selected(param1:Boolean) : void
        {
            super.selected = param1;
            if (param1)
            {
                this._selectedBg.visible = true;
            }
            else
            {
                this._selectedBg.visible = false;
            }
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_2:SInvestInfo = null;
            super.data = param1;
            this._type = param1.type as int;
            this._title.imgUrl = "MonthTabName_" + this._type + ".png";
            this._isInvestIcon.visible = this._type > 0 && InvestUtil.isHasInvestmented(this._type);
            if (this._type > 0)
            {
                _loc_2 = Cache.instance.investment.getTodayInfoByType(this._type);
                this.setRewardFlag(InvestUtil.isHasInvestmentCanGetByType(this._type));
            }
            else
            {
                this.setRewardFlag(false);
            }
            return;
        }// end function

    }
}
